<?php Yii::app()->clientScript->registerScriptFile(Yii::app()->params['static'].'assets/js/bootbox.min.js',2); ?>
<div class="page-header">
							<h1>
							所有学生
							</h1>
</div>
<div class="row">
 <div class="col-xs-12">
  <div class="row">
   <div class="col-xs-12">
										<div class="widget-box">
											<div class="widget-header widget-header-small">
												<h5 class="lighter">查询</h5>
											</div>

											<div class="widget-body">
												<div class="widget-main">
													<?php echo $this->renderPartial('_searchform',array('classRooms'=>$classRooms,'major'=>$major));?>
												</div>
											</div>
										</div>
										 
            </div>
		</div>	
 <hr>
 <div class="row">
   <div class="col-xs-12">
    <div class="widget-box">
											<div class="widget-header widget-header-small">
												<h5 class="lighter">共检索出 <?php  echo $total; ?> 条数据 </h5>
											</div>

											<div class="widget-body">
												<div class="widget-main">
											<div class="table-responsive">
											<table id="sample-table-1" class="table table-striped table-bordered table-hover">
												<thead>
													<tr>
													    <th>姓名</th>
														<th>学号</th>
														<th>年级</th>
														<th>班级</th>
														<th>专业</th>
														<th>操作</th>
													</tr>
												</thead>

												<tbody>
												<?php
											    foreach($users as $u){
													$realName = $u->stuinfo?$u->stuinfo->realName:'未添加';
													$grade = $u->stuinfo?$u->stuinfo->grade:'未添加';
													$classRoom = $u->stuinfo?$u->stuinfo->classRoom:'未添加';
													$major = $u->stuinfo?$u->stuinfo->major:'未添加';
												echo'	
												<tr id="'.$u->uId.'">
												
												<td>'.$realName.'</td>
												<td>'.$u->username.'</td>
												<td>'.$grade.'</td>
												<td>'.$classRoom.'</td>
												<td>'.$major.'</td>
												<td >
												 
												<a>
												<button reset-action= "'.$u->uId.'" class="btn btn-xs btn-warning" data-rel = "tooltip" data-original-title = "重置密码" >
												   <i class="icon-wrench bigger-100"></i>
												</button>
												</a>
                                               <button  delete-action ="'.$u->uId.'" class="btn btn-xs btn-danger" data-rel = "tooltip" data-original-title = "删除学生">
													<i class="icon-trash bigger-100"></i>
												</button>												
												</td>
											    </tr>';
												}
                                               ?>												
											    </tbody>
											
											</table>
									       <div class="col-xs-12" style="text-align:center">
										     <?php 
											 $this->widget('CLinkPager',array( 
													'htmlOptions'=>array('class'=>'pagination'),
													'cssFile'=>false,
													'header'=>'',    
													'firstPageLabel' => '首页',    
													'lastPageLabel' => '末页',    
													'prevPageLabel' => '上一页',    
													'nextPageLabel' => '下一页',    
													'pages' => $pages,    
													'maxButtonCount'=>13    
												)    
											);    
												
										?>
									</div>
			                       </div><!-- /.table-responsive -->
		                      </div>
	                     </div>
      </div>
    </div>
  </div>
 </div>  
</div>
<script type="text/javascript">

			jQuery(function($) {
               
			   //reset pass alert
			   $('[reset-action]').on('click',function(){
				   var id = $(this).attr('reset-action');
				  bootbox.confirm("确定要重置密码吗？",function(result){
					  if(result){
						
						$.post('<?php  echo Yii::app()->createUrl('adminaccounts/reset'); ?>',{"uId":id},
						function(data){
						   
							bootbox.alert(data,function(){});
							
						});  
						  
					  }
					  
				  }) 
				   
			   });
			   // delete user
              $('[delete-action]').on('click',function(){
				  var id = $(this).attr('delete-action');
				  bootbox.confirm("确定要删除吗？",function(result){
					  
					  if(result){
						  	
						$.post('<?php  echo Yii::app()->createUrl('adminaccounts/delete'); ?>',{"uId":id},
						function(data){
							data = $.parseJSON(data);
						    
							bootbox.alert(data['msg'],function(){
                                 if(data['code'] == '200'){
									  $('#'+id).fadeToggle('1200','linear',function(){
									      $(this).remove();	  
									  });
									  
									
									   
						    } 							
						    });
							 
							 
							
						});  
						  
						  
					  }
					  
				  })
				  
			  })
			 })
		
</script>


